package weaver.interfaces.jsit.action;

import com.weaver.general.BaseBean;
import com.weaver.general.Util;
import weaver.conn.RecordSet;
import weaver.docs.docs.DocManager;
import weaver.docs.docs.DocViewer;
import weaver.hrm.User;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @Title: ecology-idea
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2022-01-07
 * @Description: 修改文档目录
 * @ModifyLog:
 **/

public class WeaEditDocDirAction extends BaseBean implements Action {
    @Override
    public String execute(RequestInfo requestInfo) {
        String requestid = requestInfo.getRequestid();
        String tablename = requestInfo.getRequestManager().getBillTableName();
        User user = requestInfo.getRequestManager().getUser();
        RecordSet rs = new RecordSet();
        writeLog( ">>>>WeaEditDocDirAction" + requestid );
        try {
            rs.executeQuery( "select lx,nr2 from " + tablename + " where requestid=?",requestid );
            rs.next();
            int docid = Util.getIntValue( rs.getString( "nr2" ),-1 );
            int secid = 129;
            rs.executeUpdate( "delete docshare where docid=?",docid );
            rs.executeUpdate( "update DocDetail set seccategory=? where id=?",secid,docid);
            DocManager dm = new DocManager();
            dm.setId( docid );
            dm.setSeccategory( secid );
            dm.setUserid( user.getUID() );
            dm.setDocCreaterType( user.getLogintype() );
            //dm.setDocdepartmentid( docdepartmentid );
            dm.AddShareInfo();
            DocViewer DocViewer = new DocViewer();
            DocViewer.setDocShareByDoc( docid + "" );
            return Action.SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            requestInfo.getRequestManager().setMessageid( "111111" );
            requestInfo.getRequestManager().setMessagecontent( "Action接口异常！" );
            return Action.FAILURE_AND_CONTINUE;
        }
    }

}
